/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Ecu911_Interfaz;

import Ecu911_Negocio_Patrones.ClaseSingleton;
import java.awt.Color;

/**
 *
 * @author User
 */
public class FrmPrincipal extends javax.swing.JFrame {

    static public String idUsuarioActivo = "";
    /**
     *ME SIRVE PARA EL PATRON SINGLETON
     */
    static public String historialUsuario;
    
    /**
     * Creates new form FrmPrincipal
     */
    public FrmPrincipal() {
        initComponents();
        this.getContentPane().setBackground(Color.white);
        this.menuInhabilitado();
    }
    
    private void menuInhabilitado(){
        this.menuMantenimiento.setEnabled(false);
        this.menuReportes.setEnabled(false);
        this.menuServicios.setEnabled(false);
        
    }
    
    private void menuHabilitado(){
        this.menuMantenimiento.setEnabled(true);
        this.menuReportes.setEnabled(true);
        this.menuServicios.setEnabled(true);
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        submenuIngreso = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        menuMantenimiento = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        menuServicios = new javax.swing.JMenu();
        jMenuItem4 = new javax.swing.JMenuItem();
        menuReportes = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("ECU911 - [Pantalla Principal]");
        setMaximumSize(new java.awt.Dimension(1274, 594));
        setMinimumSize(new java.awt.Dimension(1274, 594));
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
        });

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/LogoEcu911.png"))); // NOI18N

        jMenuBar1.setBorder(new javax.swing.border.SoftBevelBorder(0));

        jMenu1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/BotonActivo.png"))); // NOI18N
        jMenu1.setText("Sistema");

        submenuIngreso.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/Ingresar.png"))); // NOI18N
        submenuIngreso.setText("Ingresar Sistema");
        submenuIngreso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                submenuIngresoActionPerformed(evt);
            }
        });
        jMenu1.add(submenuIngreso);

        jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/Salir.png"))); // NOI18N
        jMenuItem2.setText("Salir Sistema");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuBar1.add(jMenu1);

        menuMantenimiento.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/BotonActivo.png"))); // NOI18N
        menuMantenimiento.setText("Mantenimientos");

        jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/MantenimientoUsuarios.png"))); // NOI18N
        jMenuItem1.setText("Usuarios");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        menuMantenimiento.add(jMenuItem1);

        jMenuItem5.setText("Instituciones");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        menuMantenimiento.add(jMenuItem5);

        jMenuBar1.add(menuMantenimiento);

        menuServicios.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/BotonActivo.png"))); // NOI18N
        menuServicios.setText("Servicios");

        jMenuItem4.setText("Atender Llamada");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        menuServicios.add(jMenuItem4);

        jMenuBar1.add(menuServicios);

        menuReportes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Iconos/BotonActivo.png"))); // NOI18N
        menuReportes.setText("Reportes");

        jMenuItem3.setText("Actividades recientes");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        menuReportes.add(jMenuItem3);

        jMenuBar1.add(menuReportes);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(444, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(416, 416, 416))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(164, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(149, 149, 149))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-1290)/2, (screenSize.height-632)/2, 1290, 632);
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        System.exit(0);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void submenuIngresoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_submenuIngresoActionPerformed
        FrmLogIn ventanaLogin = new FrmLogIn(this, true);
        ventanaLogin.setVisible(true);
    }//GEN-LAST:event_submenuIngresoActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        historialUsuario = historialUsuario + "\nACTIVO MENU MANTENIMIENTO USUARIOS";
        ClaseSingleton.getmiClaseSingleton().setContenidos(historialUsuario);
        FrmMantenimientoUsuarios ventanaUsuarios = new FrmMantenimientoUsuarios(this, true);
        ventanaUsuarios.setVisible(true);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        historialUsuario = historialUsuario + "\nACTIVO MENU MANTENIMIENTO INSTITUCIONES";
        ClaseSingleton.getmiClaseSingleton().setContenidos(historialUsuario);
        FrmMantenimientoInstitucionesServicios ventanaInst = new FrmMantenimientoInstitucionesServicios(this, true);
        ventanaInst.setVisible(true);
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
        if(!idUsuarioActivo.equals("")){
            this.menuHabilitado();
            historialUsuario = ClaseSingleton.getmiClaseSingleton().getContenido();
            historialUsuario = historialUsuario + " " + idUsuarioActivo;
            ClaseSingleton.getmiClaseSingleton().setContenidos(historialUsuario);
        }
    }//GEN-LAST:event_formWindowActivated

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        FrmActividadReciente ventanaActividad = new FrmActividadReciente(this, true);
        ventanaActividad.setVisible(true);
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrmPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrmPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrmPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrmPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FrmPrincipal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenu menuMantenimiento;
    private javax.swing.JMenu menuReportes;
    private javax.swing.JMenu menuServicios;
    private javax.swing.JMenuItem submenuIngreso;
    // End of variables declaration//GEN-END:variables
}
